package com.yan.design.two.structure.s3;

/**
 * 3. 装饰者模式
 *      测试
 * @author shengren.yan
 * @create 2022-07-27
 */
public class testRun {

    public static void main(String[] args) {

        // 牛奶1类 + 布丁A类
        Base b = new Milk();
        Decorator d = new ADecoratorImpl(b);
        System.out.println( d.cost() );

        System.out.println("--------------");
        // 牛奶1类 + 布丁B类
        Decorator d2 = new BDecoratorImpl(d);
        System.out.println( d2.cost() );

        System.out.println("--------------");
        // 牛奶2类 + 布丁B类 + 布丁B类
        Base b2 = new Milk2();
        Decorator b2d = new BDecoratorImpl(b2);
        b2d = new BDecoratorImpl(b2d);
        System.out.println( b2d.cost() );

    }

}
